from PySide6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QLineEdit, QPushButton

from gui.widgets_map import open_window


class NewGameBoard(QWidget):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("新游戏")
        self.setGeometry(300, 300, 500, 309)

        layout = QVBoxLayout()
        layout.addStretch(1)

        enter_name_layout = QHBoxLayout()
        enter_name_layout.addWidget(QLabel('角色名:'))
        self.edit_name = QLineEdit(self)
        enter_name_layout.addWidget(self.edit_name)
        layout.addLayout(enter_name_layout)

        btn_submit = QPushButton('开始')
        btn_submit.clicked.connect(self.submit)
        layout.addWidget(btn_submit)

        layout.addStretch(1)

        self.setLayout(layout)

    def submit(self):
        player_name = self.edit_name.text().strip()
        open_window('main')
        self.close()
